<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * ssh
 *
 * @author Simon Emms <simon@simonemms.com>
 */

/* Require the SSH library */
set_include_path(get_include_path().PATH_SEPARATOR.FCPATH.APPPATH.'third_party/phpseclib');
require_once('Net/SSH2.php');

class ssh {
    
    
    
    
    
    protected $_objSSH;
    
    
    
    
    
    /**
     * Create Object
     * 
     * Creates the SSH object
     * 
     * @param string $host
     * @param bool $force_create
     * @return object
     */
    protected function _create_object($host, $force_create = false) {
        if(!is_null($this->_objSSH) || $force_create === true) {
            $this->_objSSH = new Net_SSH2($host);
        }
        
        return $this->_objSSH;
    }
    
    
    
    
    
    
    public function connect($host, $username = null, $password = null) {
        
        $this->_create_object($host);
        
        $this->_objSSH->login($username, $password);
        
    }
    
    
    
    
    
    
    public function tunnel($host, $username = null, $password = null) {
        
        echo '<pre>'.print_r($this->_objSSH, true).'</pre>';exit;
        
    }
    
    
    
    
}

?>